<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    {include file="common_header"}
    <title>添加商品</title>
    <style>
        .progress{
            width: 220px;
         font-size: 28px;
        }
        .progress-bar{
            height: 40px;
        }
    </style>
</head>
<body>
<div class="page-container">
    <form class="form form-horizontal" id="form-article-add" enctype="multipart/form-data" method="post" action="{:url('goodsadd')}">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>商品名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="请输入商品名称" id="articletitle" name="goods_name" datatype="*" nullmsg="商品名称不能为空">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2"><span class="c-red">*</span>商品分类：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select name="classify_id"  class=" select "  id="columnid" datatype="*"  nullmsg="请选择栏目">
                        <option disabled selected value="0">请选择商品类型</option>
                            {volist name='classlist' id="v"}

                               <option value="{$v['id']}"    {if condition="$v['father_id'] eq 0"} disabled{/if} >{$v['classify_name']}</option>
                            {/volist}
                     </select>
				</span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">商品封面图：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="file" class="input-text" value="" placeholder="" id="articletitle2" name="coverFile">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">商品原价：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value=""  placeholder="请输入商品价格" name="goods_price" datatype="*" nullmsg="商品价格不能为空">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">商品优惠价：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value=""  placeholder="请填写商品优惠价(不填默认原价)" name="goods_discount" >
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">价格单位：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value=""  placeholder="请填写商品价格单位  例如：kg"  name="goods_unit">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">商品库存：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value=""  placeholder="请输入商品数量" name="goods_num" nullmsg="商品库存不能为空" >
            </div>
        </div>
        <input id="imgs" type="hidden"  class="input-text" name="good_urlimg">
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">商品详情图片：</label>
            <div class="formControls col-xs-8 col-sm-9"  >
                <input id="upfile" type="file"  multiple class="file" data-overwrite-initial="false" data-min-file-count="1"  name="images">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-2">商品描述：</label>
            <div class="formControls col-xs-8 col-sm-9" >
                <textarea name="goods_content" cols="" rows="" class="textarea"  placeholder="说点什么...最少输入10个字符" datatype="*"  nullmsg="请填写商品描述" ></textarea>
            </div>
        </div>
          <div class="row cl">
              <div class="col-xs-8 col-sm-9 col-xs-offset-3">
                    <button class="btn btn-primary radius" type="submit"> 提交 </button>
                 </div>
          </div>
            </form>
       </div>
</body>
{include file="common_footer"}
<link href="__ACSS__bootstrap.css" rel="stylesheet">
<link href="__ACSS__fileinput.min.css" media="all" rel="stylesheet" type="text/css" />
<script src="__AJS__fileinput.js" type="text/javascript"></script>
<script src="__AJS__bootstrap.js" type="text/javascript"></script>
<script src="__AJS__zh.js" type="text/javascript"></script>
<script type="text/javascript">

        // 初始化fileinput控件,第一次初始化 (控件id，上传地址)
    initFileInput("upfile", "uploadImg");
    // 初始化filleinput控件  第一次初始化
    function initFileInput(ctrlName, uploadUrl){
        var control = $('#'+ctrlName);
        control.fileinput({
            language: 'zh', //设置语言
            uploadUrl:uploadUrl,    //上传的地址
            allowedFileExtensions:['jpg','png'],    //接收的文件后缀
            showUpload:true,    //是否显示上传按钮
            showCaption:false,    //是否显示标题
            maxFileSize: 1000,    //图片最大尺寸kb 为0不限制
            maxFilesNum: 6,        //最多上传图片
            overwriteInitial: false,//不覆盖已上传的图片
            browseClass: "btn btn-info", //按钮样式
            dropZoneEnabled: true,//是否显示拖拽区域
            previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
            msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
            initialPreviewAsData: true,
            layoutTemplates :{
               actionUpload:''
            }
        });
    }
    /**
     *上传完路径之后插入自定的数组中
     * 更新input中的值
     */
   var List = new Array();//定义一个全局变量去接受文件名和id
   $("#upfile").on("fileuploaded", function(event, data, previewId, index) {
       var data = data.response.url;  //文件上传成功返回的文件名，可返回自定义文件名
       console.log(data);
       List.push({ FileName: data, KeyID: previewId });
       var url="";
       var imgs=$("#imgs").val();
       if(!imgs){
           url=data;
       }else{
           url=imgs+','+data;
       }
     $("#imgs").val(" ");
     $("#imgs").val(url);
   })
   /**
    *删除数据后更新自定义数组
    * 更新input中的值
    */
   $("#upfile").on("filesuccessremove", function (event, data, previewId,url) {
       var urls="";
       for (var i = 0; i < List.length; i++) {
           if (List[i].FileName== url) {
               List.splice(i,1);
           }
       }
       for (var j = 0; j < List.length; j++){
           urls+=List[j].FileName+',';
       }
       $("#imgs").val(" ");
       $("#imgs").val(urls);
   });
   /**
    * 清空所有文件上传框的所有图片
    */
   $("#upfile").on("fileclear", function () {
       $("#imgs").val(" ");
   });
</script>
</html>